﻿using System.Security.Cryptography;
using System.Text;

/// <summary>
/// MD5加密帮助类
/// </summary>
public static class MD5Helper
{
    /// <summary>
    /// MD5加密
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public static string Encrypt(string data)
    {
        MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
        byte[] dataHashed = md5Hasher.ComputeHash(Encoding.Default.GetBytes(data));
        StringBuilder sBuilder = new StringBuilder();
        for (int i = 0; i < dataHashed.Length; i++)
        {
            sBuilder.Append(dataHashed[i].ToString("x2"));
        }
        return sBuilder.ToString();
    }
}
